package cn.xo68.ide.plugin.common.ui.generate;

import cn.xo68.ide.plugin.common.swing.treetable.CheckContextProvider;
import com.wy2.generator.database.entity.DatabaseTable;

import javax.swing.event.ChangeListener;

public class CodeGenerateTableContext extends CheckContextProvider<DatabaseTable> {

    private final DatabaseTable context;

    public CodeGenerateTableContext(DatabaseTable context, ChangeListener checkStateChangeListener) {
        super(false, checkStateChangeListener);
        this.context = context;
    }

    public CodeGenerateTableContext(boolean checked, ChangeListener checkStateChangeListener, DatabaseTable context) {
        super(checked, checkStateChangeListener);
        this.context = context;
    }

    @Override
    public DatabaseTable getContext() {
        return context;
    }

    @Override
    public String getCheckText() {
        return context.getSqlName();
    }

    @Override
    public Object getValueAt(int i) {
        switch(i) {
            case 0:
                return context.getSqlName();
            case 1:
                return context.getEntityName();
            case 2:
                return context.getModule();
        }
        return null;
    }
}
